<?php include "checkSessionForAuthen.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Chỉnh Sửa Thông Tin Tuyển Dụng</title>
        <?php include("import.php"); ?>
    </head>

    <body>
        <?php
        include("../service/recruitmentService.php");
        ?>
        <form action="../action/editRecruitmentAction.php" enctype="multipart/form-data" method="post" id="form">
            <!--header-->
            <?php include "header.php"; ?>
            <!--end header-->
            <!-- Container -->
            <div id="container">
                <div class="shell">

                    <!--
                    <div class="small-nav">
                            <a href="product.html">Tài Khoản</a>
                            <span>&gt;</span>
                            anv
                    </div>
                    -->

                    <!-- End Small Nav -->
                    <?php
                    $message = "";
                    if (isset($_GET['message'])) {
                        $deleteMessage = $_GET['message'];
                    }
                    if (isset($deleteMessage)) {
                        if ($deleteMessage == 'ok') {
                            $message = 'Thông tin đã được thay đổi thành công!';
                        } else {
                            $message = 'Không thể thay đổi thông tin';
                        }
                    }

                    if ($message == '') {
                        $class = 'msg msg-ok msg-hidden';
                    } else {
                        $class = 'msg msg-ok';
                    }
                    ?>	
                    <div class="<?php echo($class); ?>" id="msgOK">
                        <p><strong><?php echo($message); ?></strong></p>
                        <a href="#" onclick="hideMessage()" class="close">close</a>
                    </div>
                    
                    <br />
                    <!-- Main -->
                    <div id="main">
                        <div class="cl">&nbsp;</div>

                        <!-- Content -->
                        <div id="content">        
                            <!-- Box -->
                            <div class="box">
                                <!-- Box Head -->
                                <div class="box-head">
                                    <h2>Chỉnh Sửa Thông Tin Tuyển Dụng</h2>
                                </div>
                                <!-- End Box Head -->

                                <?php
                                if (isset($_GET["id"])) {
                                    $result = getRecruitmentById($_GET["id"]);
                                    while ($row = ConnectionManager::getInstance()->fetchArray()) {
                                        ?>
                                        <!-- Form -->
                                        <div class="form">
                                            <p>
                                                <input type="hidden" name="recid" id="insid" value="<?php echo $row["REC_ID"]; ?>"/>
                                                <textarea id="content" name="content" class="ckeditor"><?php echo $row["REC_CONTENT"]; ?></textarea>
                                            </p>
                                        </div>
                                        <!-- End Form -->
                                        <?php
                                    }
                                }
                                ?>
                                <!-- Form Buttons -->
                                <div class="buttons">
                                    <input type="submit" class="button" value="Chấp nhận"/>
                                    <input type="button" class="button" value="Trở Về" onclick="window.location='recruitment.php'" />
                                </div>
                                <!-- End Form Buttons -->

                            </div>
                            <!-- End Box -->

                        </div>
                        <!-- End Content -->	
                        <div class="cl">&nbsp;</div>			
                    </div>
                    <!-- Main -->
                </div>
            </div>
            <!-- End Container -->
            <?php
            if (isset($_GET["updateRec"])) {
                $recID = $_GET["recid"];
                $name = $_GET["content"];
                updateRecruitment($recID, $name);
                echo("<script>window.location.href='recruitment.php';</script>");
            }
            ?>
            <!--footer-->
            <?php include "footer.php"; ?>
            <!--end footer-->
            <?php ConnectionManager::getInstance()->closeConnection(); ?>
        </form>
    </body>
</html>
</html>